import 'package:flutter/material.dart';
import '../reactive/video_page_state.dart';

// 影片页面数据供给者
class VideoPageProvider extends InheritedWidget {
  final VideoPageHoistedState reactiveState; // 响应式状态

  const VideoPageProvider({
    Key key,
    @required this.reactiveState,
    @required Widget child,
  }) : super(key: key, child: child);

  static VideoPageHoistedState of(BuildContext ctx) {
    final VideoPageProvider res = ctx.dependOnInheritedWidgetOfExactType<VideoPageProvider>();
    assert(res != null, "当前的上下文中未找到VideoPageProvider实例");
    return res.reactiveState;
  }

  @override
  bool updateShouldNotify(VideoPageProvider oldWidget) {
    return oldWidget.reactiveState != reactiveState;
  }
}
